package com.neusoft.movie.v_movies.adpater;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.neusoft.movie.v_movies.R;
import com.neusoft.movie.v_movies.javabean.CommentBean;
import java.util.List;


public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context mContext;
    private List<CommentBean> mDataList;
    private LayoutInflater mLayoutInflatera;

    public CommentListAdapter(Context mContext,List mDataList){
        this.mContext = mContext;
        this.mDataList = mDataList;
        mLayoutInflatera = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflatera.from(parent.getContext())
                .inflate(R.layout.cardview_commentlist, parent, false);
        return new ViewHolder(v);

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final CommentBean entity = (CommentBean) mDataList.get(position);
        if (null == entity)
            return;
        //绑定数据
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.userName.setText(entity.getU_name());
        viewHolder.info.setText(entity.getCom_content());
        viewHolder.Time.setText(entity.getCom_time());


    }


    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView Time;
        TextView userName;
        TextView info;

        public ViewHolder(View itemView){
            super(itemView);
            userName = (TextView) itemView.findViewById(R.id.u_name);
            info = (TextView) itemView.findViewById(R.id.com_content);
            Time = (TextView) itemView.findViewById(R.id.com_time);

        }
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }
}
